import { Entity, Column, PrimaryGeneratedColumn, CreateDateColumn, UpdateDateColumn } from 'typeorm';

@Entity('sys_user')
export class User {
    @PrimaryGeneratedColumn({ comment: '用户ID' })
    id: number;

    @Column({ length: 50, unique: true, comment: '用户名' })
    username: string;

    @Column({ length: 100, select: false, comment: '密码' })
    password: string;

    @Column({ length: 200, nullable: true, comment: '头像URL' })
    avatar: string;

    @Column({ length: 50, nullable: true, unique: true, comment: '邮箱' })
    email: string;

    @Column({ length: 20, nullable: true, comment: '手机号' })
    phone: string;

    @Column({ length: 50, nullable: true, comment: '真实姓名' })
    realName: string;

    @Column({ length: 500, nullable: true, comment: '备注' })
    remark: string;

    @Column({ default: 0, comment: '部门ID' })
    deptId: number;

    @Column('simple-array', { comment: '角色ID列表' })
    roleIds: number[];

    @Column({ 
        type: 'tinyint',
        default: 1, 
        comment: '账号状态(1-正常, 0-禁用)' 
    })
    status: number;

    @Column({ length: 50, nullable: true, comment: '创建者' })
    createBy: string;

    @CreateDateColumn({ comment: '创建时间' })
    createTime: Date;

    @Column({ length: 50, nullable: true, comment: '更新者' })
    updateBy: string;

    @UpdateDateColumn({ comment: '更新时间' })
    updateTime: Date;

    @Column({ 
        type: 'tinyint',
        default: 0, 
        comment: '删除标志(0-存在, 1-删除)' 
    })
    delFlag: number;
} 